package com.ordersys.cloud.apis;


import com.ordersys.cloud.domain.R;
import com.ordersys.cloud.entity.PayDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;


@FeignClient(value = "cloud-payment-service")  //通过OpenFeign直接调用支付微服务
public interface PayFeignApi {

    @PostMapping(value = "/pay/add")
    public R addPay(@RequestBody PayDTO pay);

    @GetMapping(value = "/pay/del/{id}")
    public R deletePay(@PathVariable("id") Integer id);

    @PostMapping(value = "/pay/update")
    public R updatePay(@RequestBody PayDTO payDTO);


    @GetMapping(value = "/pay/get/{id}")
    public R getPayById(@PathVariable("id") Integer id);


    @GetMapping("/pay/getPayAllList")
    public R getPayAllList();


    @GetMapping(value = "/pay/get/info")
    public String getInfoByConsul();

    @GetMapping(value = "pay/get/serviceInfo")
    public String getServiceInfo();


    //Resilience4j CircuitBreaker 的示例
    @GetMapping(value = "/pay/circuit/{id}")
    public String myCircuit(@PathVariable("id") Integer id);


    //Resilience4j Bulkhead 的例子
    @GetMapping(value = "/pay/bulkhead/{id}")
    public String myBulkhead(@PathVariable("id") Integer id);


    //Resilience4j Ratelimit 的例子
    @GetMapping(value = "/pay/ratelimit/{id}")
    public String myRatelimit(@PathVariable("id") Integer id);

    //sentinel 限流
    @GetMapping(value = "/pay/sentinel/fc/{id}")
    public R sentinelFC(@PathVariable("id") Integer id);

    //sentinel 熔断降级
    @GetMapping(value = "/pay/sentinel/circuit/{id}")
    public R<String> sentinelCircuit(@PathVariable("id") Integer id);



    /*
  添加如下两个调用方法
  */
    // GateWay进行网关测试接口1
    @GetMapping(value = "/pay/gateway/get/{id}")
    public R gateWayGetPayById(@PathVariable("id") Integer id);

    // GateWay进行网关测试接口2
    @GetMapping(value = "/pay/gateway/info")
    public R<String> getGatewayInfo();


    /**
     * Micrometer(Sleuth)进行链路监控的例子
     * @param id
     * @return
     */
    @GetMapping(value = "/pay/micrometer/{id}")
    public String myMicrometer(@PathVariable("id") Integer id);

}


